﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="shipu_clone01.aspx.cs" Inherits="Catering.Catering_Page.Caipin.shipu_clone01" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../../../Style/head.css" />
    <link rel="stylesheet" type="text/css" href="../../../Style/center.css" />
    <link href="../../../Style/zhezhao.css" rel="stylesheet" type="text/css" />
    <script src="../../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../../Style/zhezhao.js"></script>
</head>
<script type="text/javascript">
    $(document).ready(function () {
        //增加按钮开始
        $("#AddInfo").click(function () {
            var SexOption = "<%=GetSexOption()%>";
            var AgeOption = "<%=GetAgeOption()%>";
            var LaborOption = "<%=GetLaborOption()%>";

            Xuhao = $("#Tbody_Pic_Group tr").length + 1;
            var i = Math.floor(Math.random() * 1000 + 1);
            $("#Tbody_Pic_Group").append("<tr id=\"Add_" + i + "\">"
                            + "<td name=\"Add\">" + Xuhao + "</td>" //序号
                            + "<td>" + SexOption + "</td>" //性别
                            + "<td>" + AgeOption + "</td>" //年龄
                            + "<td>" + LaborOption + "</td>" //劳动强度
                            + "<td> <input type=\"text\" style=\"width:50%\" id=\"Renshu\" name=\"Renshu\" value=\"\" /></td>" + //人数
                            "<td><img alt=\"\" id=\"del\" name=\"del\" onclick=\"Del_tr('" + i + "')\" style=\"cursor:pointer;\" src=\"../../../Images/trash.gif\"/></td></tr>"); //删除
        });

        $("#Dr_zuoye").change(getShuoMingStr);
        getShuoMingStr();
    });

    //配餐人群特点说明
    function getShuoMingStr() {
        var sel = $("#Dr_zuoye").val();
        $.ajax({
            type: "Post",
            url: "shipu_clone01.aspx/GetShuoMingStr",
            data: "{'id':'" + sel + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                document.getElementById("pop").innerText = data.d[0];
            }
        });
    }
    //移除
    function Del_tr(n) {
        $("#Add_" + n).remove();
    }

    function Group_Next_But_Click_Js() {
        var title = $("#Txt_Pic_name").val();
        if (title == "") {
            alert("请输入配餐群体名称！");
            return;
        }
        var count = $("#Tbody_Pic_Group tr").length;
        if (count == 0) {
            alert("请添加人数！");
            return;
        }
        var num = 0;
        $("#Tbody_Pic_Group tr").each(function () {
            num += $(this).find("[name='Renshu']").val();
        });
        if (num == 0) {
            alert("请添加人数！");
            return;
        }
        if ($("#But_Pic_Next").is("[disabled]")) {
            alert("请进行加权平均计算！");
            return;
        }
        $("#But_Pic_Next").click();
    }

    function AVG_But_Click() {
        var title = $("#Txt_Pic_name").val();
        if (title == "") {
            alert("请输入配餐群体名称！");
            return;
        }
        var strTypes = "";
        $("#Tbody_Pic_Group tr").each(function () {
            strTypes += $("#Dr_zuoye").val() + //使用人群
                        "|" + $(this).find("[name='sex']").val() + //性别
                        "|" + $(this).find("[name='Age']").val() + //年龄段
                        "|" + $(this).find("[name='Labor']").val() + //劳动级别
                        "|" + $(this).find("[name='Renshu']").val() + ","; //人数
        });

        if (strTypes == "")
            return;

        $.ajax({
            type: "Post",
            url: "shipu_clone01.aspx/GetJiaQuanPJ",
            data: "{'strTypes':'" + strTypes + "'}",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                if (data.d[0] == "OK") {
                    var title = new Array("能量（千卡）", "能量（千焦）", "蛋白质（克）", "脂肪(千卡)", "碳水化合物(克)", "膳食纤维（千卡）", "维生素A（毫克）", "维生素B1（微克）", "维生素B2（毫克）", "维生素C（毫克）", "维生素E（毫克）", " 视黄醇当量（毫克）", "尼克酸(毫克)", "胡萝卜素(mg)", "钙", "磷", "钾", "钠", "镁", "铁", "锌", "硒", "铜", "锰", "碘");
                    var strhtml = "";
                    for (var i = 1; i <= 25; i++) {
                        strhtml += "<tr onmouseover=\"this.style.background='#F4F4F4'\" onmouseout=\"this.style.background='#FFFFFF'\"><td class=\"xh_td\">" + title[i - 1] + "</td>";
                        strhtml += "<td align='center'>" + data.d[i] + "</td>";
                        strhtml += "<td align='center'>" + fomatFloat((parseInt(data.d[i].toString()) / 10 * 3).toString(), 2) + "</td>";
                        strhtml += "<td align='center'>" + fomatFloat((parseInt(data.d[i].toString()) / 10 * 4).toString(), 2) + "</td>";
                        strhtml += "<td align='center'>" + fomatFloat((parseInt(data.d[i].toString()) / 10 * 3).toString(), 2) + "</td>";
                        //strhtml += "<td align='center'>" + fomatFloat((parseInt(data.d[i].toString()) / 10 * 4).toString(), 2) + "</td></tr>";
                        strhtml += "</tr>";
                    }

                    $("#NutritionalList").html(strhtml);
                    $("#But_Pic_Next").removeAttr("disabled");

                    divshow("divmain2", "divup2");
                }
                else {
                    alert("存在无摄入量标准的类别组合！");
                }
            }
        });
    }

    function fomatFloat(src, pos) {
        return Math.round(src * Math.pow(10, pos)) / Math.pow(10, pos);
    }
</script>
<body>
    <form id="form1" runat="server">
    <div class="nav_2">
        <div class="nav_2_1">
            <img src="../../../Images/nav2_bg1.gif" /></div>
        <ul>
            <li><a href="javascript:void(0);"><span id="span_peic_1" class="lvse_border">1.配餐人群设置</span></a></li>
            <li><a href="javascript:void(0);"><span id="span_peic_2" class="feise_border">2.选择配餐日期</span></a></li>
            <li style="background: none"><a href="javascript:void(0);"><span id="span_peic_3" class="feise_border">3.生成食谱</span></a></li>
        </ul>
        <div class="nav_2_3">
            <img src="../../../Images/nav2_bg2.gif" /></div>
    </div>
    <div class="table_box">
        <div class="xxk_button"></div>
        <div class="table_box02" id="div2_1" style="display: block;">
            <div class="table_box02_01" style="height:auto;">
                <h1>&nbsp;</h1><br />
                <table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_css">
                    <tr>
                        <td class="width155" > 配餐群体名称：</td>
                        <td valign="middle">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox runat="server" ID="Txt_Pic_name" CssClass="input_bg" Style="width: 155px; height: 22px; line-height: 22px;" /></td>
                    </tr>
                    <tr>
                        <td class="width155" >配餐群体类别：</td>
                        <td valign="middle">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:DropDownList ID="Dr_zuoye" runat="server" class="select_input_bg"></asp:DropDownList>
                        </td>
                    </tr>
                    <tr style=" display:none;">
                        <td class="width155">
                            配&nbsp;&nbsp;餐&nbsp;&nbsp;餐&nbsp;&nbsp;别：
                        </td>
                        <td class="input_margin" align="left">
                            <asp:CheckBoxList runat="server" ID="CL_Pic_FoodMealType" Style="margin:0px; padding:0px;"
                                RepeatDirection="Horizontal">
                                <asp:ListItem Value="1" Selected="True">早餐</asp:ListItem>
                                <asp:ListItem Value="2" Selected="True">中餐</asp:ListItem>
                                <asp:ListItem Value="3" Selected="True">晚餐</asp:ListItem>
                                <asp:ListItem Value="4" Selected="True">夜餐</asp:ListItem>
                            </asp:CheckBoxList> 
                        </td>
                    </tr>
                    <tr>
                        <td class="width155" valign="middle">
                            配餐群体特点：
                        </td>
                        <td>
                            <div id="pop" class="input_bg" style="width:630px; height:100px; line-height: 25px; margin-left:14px; overflow-y:auto;"></div>
                        </td>
                    </tr>
                    <tr>
                        <td class="width155" valign="middle">
                            配餐群体描述：
                        </td>
                        <td style="padding:0px 0px 10px 0px;">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<asp:TextBox runat="server" ID="Txt_Pic_Te" CssClass="input_bg" Style="width: 630px;
                                height: 40px; line-height: 25px;" />
                        </td>
                    </tr>
                </table>
            </div>
            <div class="table_box02_02">
                <h1>&nbsp;</h1>
                <table id="Tb_Pic_Group" width="100%" border="0" cellspacing="0" cellpadding="0"
                    class="top_left_table">
                    <thead>
                        <tr class="top_td">
                            <th width="80px">
                                序号
                            </th>
                            <th width="123px">
                                性别
                            </th>
                            <th width="102px">
                                年龄
                            </th>
                            <th width="306px">
                                劳动级别
                            </th>
                            <th width="155px">
                                人数
                            </th>
                            <th>
                                删除
                            </th>
                        </tr>
                    </thead>
                    <tbody id="Tbody_Pic_Group" runat="server">
                        
                    </tbody>
                </table>
                <div class="button_add_pos">
                    <a href="javascript:void(0);" class="img_pos">
                        <img src="../../../Images/jqjs.gif" id="AVG_But" onclick="AVG_But_Click()" /></a>
                    <a href="javascript:void(0);" class="add_botton">
                        <img id="AddInfo" src="../../../Images/add.gif" /></a>
                </div>
                <div style="clear: both; height: 50px;">
                </div>
            </div>
            <div class="table_box02_03">
                <asp:Button ID="But_Pic_Next" Enabled="false" runat="server" OnClick="Group_Next_But_Click"
                    Style="display: none" />
                <a style="cursor:pointer;" onclick="Group_Next_But_Click_Js()">下一步</a>
            </div>
        </div>
        
    </div>
    <div class="footer">
        <strong>中海油能源发展配餐服务公司渤海自营油田作业公司&nbsp;&nbsp;版权所有@CopyRight 2012</strong><span>技术支持：北京天择嘉业科技有限公司</span>
    </div>
    </form>
    <!--遮罩层-->
    <div id="divmain2" class="bg">
    </div>
    <!--弹出层-->
    <div id="divup2" class="center_div" style="padding: 0px; margin-top: -150px;">
        <table style="width: 100%;">
            <tr width="100%">
                <td>
                    <div class="div_0207 left_width400" style="width: 100%; height: 400px; overflow-y: auto;">
                        <h1>
                            <img src="../../../Images/cp_h1_03.gif" />营养元素推荐量列表</h1>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="swxx_table">
                            <thead>
                                <tr>
                                    <td style="width: 120px;" class="table_title">营养元素</td>
                                    <td class="table_title">推荐量</td>
                                    <td class="table_title">早餐</td>
                                    <td class="table_title">中餐</td>
                                    <td class="table_title">晚餐</td>
                                    <%--<td class="table_title">夜餐</td>--%>
                                </tr>
                            </thead>
                            <tbody id="NutritionalList">
                            </tbody>
                        </table>
                    </div>
                </td>
            </tr>
            <tr align="center" width="100%">
                <td align="center" class="close_imgbtn">
                    <a href="#" class="closebtn" onclick='divhidel("divmain2","divup2")'>关　闭</a><br />
                </td>
            </tr>
        </table>
    </div>
</body>
</html>
